import { useEffect } from 'react';
import useLatest from './usesLatest';

export default function useUnmount(fn: Function) {
  const cacheFn = useLatest(fn);
  useEffect(() => () => cacheFn(), []);
}
